<!DOCTYPE html>
<html manifest="/manifest/pano.appcache">
<head>
    <title><%= title %></title>
    <meta name="description" content="<%= description %>"/>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <meta name="viewport" content="width=device-width,user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="robots" content="all">
    <link rel="stylesheet" href="/stylesheets/benzarena.css">
    <style>
        @-ms-viewport { width:device-width; }
        @media only screen and (min-device-width:800px) { html { overflow:hidden; } }
        html { height:100%; }
        body { width:100%;height:100%;overflow:hidden; margin:0; padding:0;  font-family: "Helvetica Neue",Helvetica,Hiragino Sans GB,Open Sans,Microsoft Yahei,Arial; font-size:16px;
            -webkit-tap-highlight-color:rgba(0,0,0,0);
            -ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;}

        .three_btn{position:absolute;left:50%;-webkit-transform: translate(-50%);-ms-transform: translate(-50%);transform: translate(-50%);top:-60px;}
        .three_btn .li_cir{width:50px;height:50px;background: #1D6699;line-height:50px;color:white;float:left;
            border-radius: 50%;font-size:12px;text-align:center;margin-right: 3px;}
        .three_btn .btn3{margin-right:0;}
        .togg_three_btn{width:60px;height:40px;background: rgba(0,0,0,0.6);position:absolute;top:0;left:50%;margin-left:-30px;}
        .togg_three_btn p{color:white;font-size:20px;line-height: 40px;text-align:center;transform:rotate(90deg);-webkit-transform:rotate(90deg);}
        .site-loading{width:100%;height:100%;background: #CBD3FF;position:absolute;left:0;top:0;z-index:20000;}
        .site-loading .load_img{width:64px;height:64px;
            background: url(/stylesheets/images/load.gif) no-repeat center center;
            position:absolute;top:50%;margin-top:-32px;left:50%;margin-left:-32px;}
    </style>

</head>
<body>

<div id="pano-container" style="width:100%;height:100%;" data-role="page"><noscript> <table style="width:100%;height:100%;"><tr style="valign:middle;"><td><div style="text-align:center;"> 错误:<br /><br />Javascript 没有激活<br /><br /> </div> </td></tr></table></noscript></div>
<!--<div class="site-loading"><div class="load_img"></div></div>-->
<div class="cover_hei"></div>
<div class="get_start">
    <div class="get_start_btn midi_green"><p>GET STARTED <span class="icon-long-arrow-right"></span></p></div>
    <!--<div class="conditions"><a href="#">TERMS&CONDITIONS</a></div>-->
</div>
<div class="start_banner midi_black">
    <div><img src="/stylesheets/images/midi_logo.png" /></div>
</div>
<!--菜单-start-->
<div class="htmleaf-container">
    <div id='ss_menu'>
        <div class="icon-bg eye midi_green">
            <i class="icon-eye-slash"></i>
            <p>HIDDEN</p>
        </div>
        <div class="icon-bg map midi_green">
            <i class="icon-map-marker"></i>
            <p>TAG</p>
        </div>
        <div class="icon-bg commenting midi_green">
            <i class="icon-commenting-o"></i>
            <p>SAY</p>
        </div>
    </div>
    <div class='menu midi_green'>
        <div class='share' id='ss_toggle' data-rot='180'>
            <div class="tag_text"><p>TAG</p></div>
            <img  class="tag_img"src="/stylesheets/images/tag_on.png" />
        </div>
    </div>
</div>
<!--菜单-end-->
<!--标注粉丝-start-->
<div class="comment-modal-mobile   wx_n" >
    <p style="float: left" class="no_wx_p hidden">微信中打开才能留言哟!</p>
    <a href="javascript:void(0);" class="no_wx_cancel hidden cancel" style="float: right;background:#4DB419;">知道了</a>
    <ul class="comment_ul">
        <li ><a href="javascript:void(0);" class="login midi_color"style="background:#4DB419;">授权登录</a></li>
        <li><a href="javascript:void(0);" class="cancel midi_color">取消</a></li>
    </ul>

</div>
<div class="comment-modal-mobile   wx_y" >
    <!--<p style="float: left">微信中打开才能留言哟!</p>-->
    <input type="text" style="border:1px solid #4DB419;" placeholder="你想要说的话" maxlength="12">
    <ul class="comment_ul">
        <li class="comment_li"><a href="javascript:void(0);" class="cur sure midi_color">确定</a></li>
        <li><a href="javascript:void(0);" class="cancel midi_color">取消</a></li>
    </ul>
</div>
<!--标注粉丝-end-->
<!--zoom-start-->
<div class="zoom_nav" id="zoom">
    <div class="zoom_in" >
        <span class="icon-plus midi_green"></span>
    </div>
    <div class="nav_bar"></div>
    <div class="zoom_out">
        <span class="icon-minus midi_green"></span>
    </div>
</div>
<!--zoom-end-->
<!--刷新按钮-->
<div class="refresh midi_green"><span class="icon-refresh"></span></div>
<!--fans按钮-start-->
<div class="fans_btn midi_green">
    <span class="icon-user"></span>
    <p>FANS</p>
</div>
<!--男粉与女粉列表页-->
<div class="fans_list_box">
    <div class="fans_hd midi_green">
        <ul class="fans_head">
            <li class="fans_head_cur woman_btn"><span>女粉</span><spna class="icon-venus"></spna></li>
            <li class="man_btn"><span>男粉</span><spna class="icon-mars"></spna></li>
        </ul>
        <div class="fans_list_close"><span class="icon-close"></span></div>
    </div>
    <div class="list_inner">
        <div class="fans_bd">
            <ul id="fans_list_woman" class="fans_list">
            </ul>
            <ul id="fans_list_man" class="fans_list">

            </ul>
            <div class="pullUp_woman pullUp">
                <span class="icon-spinner"></span><span class="pullUpLabel">加载更多...</span>
            </div>
            <div class="pullUp_man pullUp">
                <span class="icon-spinner"></span><span class="pullUpLabel">加载更多...</span>
            </div>
        </div>
    </div>
    <div class="add_height" ></div>
</div>
<div class="tag_loading"style="color:#4DB419;"><p>Loading...</p></div>
<!--fans按钮-end-->

<!--game的div样式-start-->
<div class="game_btn midi_green"><span class="icon-gamepad"></span> <p>GAME</p></div>
<div class="game-area">
    <ul>
        <li class="user-area midi_border">
            <div class="user-img"><img src="/stylesheets/images/init_pic.png" width="100%"/></div>
            <div class="user-name"><p>name</p></div>
        </li>
        <li class="found-area midi_border">
            <div class="user-found"><p>Found</p></div>
            <div class="user-num"><span class="num1" stype="color:#4DB419;">0</span><span class="num2" stype="color:#4DB419;">/20</span></div>
        </li>
        <li class="rank-area midi_border"><div class="rank_btn"><img src="/stylesheets/images/rank_btn.png" height="100%"/></div></li>
    </ul>
</div>
<!--game的div样式-end-->
<!--所有的小黑人找到的提示-->
<div class="start_game_tip"><img src="/stylesheets/images/start_click_hot.png" width="100%"/><span class="icon-close tip" style="color:#4DB419;"></span></div>
<div class="end_game_tip"><img src="/stylesheets/images/end_click_hot.png" width="100%"/><span class="icon-close tip" style="color:#4DB419;"></span></div>
<!--game的div样式-end-->
<!--game-list积分列表-->
<div class="game_list_box">
    <div class="game_score_hd midi_green">
        <div class="hd_title"><img src="/stylesheets/images/rank_title.png" /></div>
        <div class="game_list_close"><span class="icon-close"></span></div>
    </div>
    <div class="list_inner">
        <div class="game_score_bd">
            <ul class="game_list">
            </ul>
            <div class="pullUp_game_score pullUp">
                <span class="icon-spinner"></span><span class="pullUpLabel">加载更多...</span>
            </div>
        </div>
    </div>
    <div class="add_height" ></div>
</div>
<!--暂时的三个按钮-start-->
<div class="togg_three_btn"><p> > </p></div>
<div class="three_btn">
    <ul>
        <li class="btn1 li_cir"><p>FANS</p></li>
        <li class="btn2 li_cir"><p>TEAMS</p></li>
        <li class="btn3 li_cir"><p>BRAND</p></li>
    </ul>
</div>
<!--暂时的三个按钮-end-->
<script src="http://apps.bdimg.com/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://cdn.bigpixel.cn/libs/krpano/1.18.5/tour.js"></script>
<script src="/scripts/bigpixel.base.js"></script>
<script src="/scripts/bigpixel.panoviewer.js"></script>
<script src="/scripts/toucher.js"></script>

<script>
    var panoinfo = {panoid:'<%= panoid%>', title:'<%= title%>', description:'<%= description%>', tourxmlpath:'<%= tourxmlpath%>'};
    panoinfo.tourxmlpath = panoinfo.tourxmlpath + "?t=" +(new Date()).getTime();

    var arr_tags=[];   //
    var lone_name=[];
    var wx_friend_name='我';
    //微信json
    var socialinfo;
    //初始化全景视图
    function initPanoview(){
        bpsviewer=new BigPixelViewer(panoinfo.tourxmlpath,panoinfo.panoid);
        document.bpsviewer=bpsviewer;
        bpsviewer.embed();
    }
    //判断字节长度
    function fucCheckLength(strTemp)
    {
        var i,sum;
        sum=0;
        if(strTemp){
            for(i=0;i<strTemp.length;i++){
                if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255)){
                    sum=sum+1;
                }else{
                    sum=sum+2;
                }
            }
        }
        return sum;
    }
    //标注自己开始按钮
    $(".map").click(function(){
        tag_area();
    });
    //授权登录按钮按下
    $(".comment_ul .login").on('click',function(){
        $.bigpixel.login();
    });
    //取消按钮按下
    $(".cancel").click(function(){
        $(".wx_n").slideUp(100);
        $(".wx_y").slideUp(100);
        nav_show();
        bpsviewer.call("set(hotspot[tagger].visible,false);");
    });
    $("input").bind("input propertychange",function(){
        if($(this).val().length>0){
            $(".comment_ul .comment_li a").removeClass("cur");
        }else{
            $(".comment_ul .comment_li a").addClass("cur");
        }
    });
    //当标注点要说的内容写完，按确定按钮时：user_openid是存在的，
    $(".comment_ul .comment_li .sure").click(function(){
        var text=$("input").val();
        if(text.length>0){
            saveTag();
        }
    });
    //根据当前用户的user_openid把当前用户的id加到链接里
    function getposition_share_id(share_id){
        var htmlpath = String(document.location);
        // alert(htmlpath);
        var qmark = htmlpath.indexOf("?")
        if (qmark > 0)
            htmlpath = htmlpath.substring(0,qmark);
        var parameters ="?share_id=" + share_id;
        var link = htmlpath + parameters;
        window.history.replaceState({},"mididemo" ,link);
        socialinfo.link = window.location.href.replace(window.location.hash, '');
        //alert('link='+link);
        initWechatShare();
    }
    //聚焦到标签所标注的地方
    function lookarea(){
        var urlnow=window.location.href;
        if(urlnow.indexOf("share_id")!=-1){
            var query_url=window.location.search;
            var arr=query_url.split('=');
            var share_n=arr[1].replace('&from','');
            getbzbyopenid(share_n);   //根据链接上截取别人的openid获取别人的标注信息
        }else{
           // console.log('登录'+$.bigpixel.isLoggedIn());
            if($.bigpixel.isLoggedIn())
            {
                getbzbyopenid($.currentUser._id);   //根据链接上截取别人的openid获取别人的标注信息
            }else{
                bpsviewer.call("lookto(176.9,5.07,80);");
            }
        }
    }
    //根据链接上截取别人的openid获取别人的标注信息
    function getbzbyopenid(userid){
        //alert('id='+userid);
        var _url="/service/panos/"+panoinfo.panoid+"/usertags?userid="+userid;
        $.bigpixel.AjaxGetJson(_url,function(err,data) {
            if (!err) {
               // console.log(JSON.stringify(data));    //注意是title还是note
                //alert(data.data[0].title);
                if(data.data[0].note) {   //判断如果链接上的用户有说过话且链接上的id号不等于当前的id号时进行zoom到链接上的位置
                    looktoTag(data);
                    setTimeout(function(){
                        if($.bigpixel.isLoggedIn())
                        {
                            wx_friend_name= $.currentUser.nickname;
                            getposition_share_id($.currentUser._id);   //如果user_openid不为空，根据当前用户的user_openid把当前用户的id加到链接里
                        }else{
                            wx_friend_name=data.data[0].userinfo.nickname;
                        }
                        socialinfo = {
                            title:wx_friend_name+"在<%= title%>",
                            desc:"<%= description%>",
                            link:window.location.href.replace(window.location.hash, ''),
                            imgUrl:'<%= iconPath%>'
                        };
                        initWechatShare();
                    },2000);

                }
            }
        });
    }
    function looktoTag(data){
        // console.log(JSON.stringify(data));
        var userData=data.data?data.data[0]:data;
        var active_tag='new_tag_bar'+userData.userinfo.userid;
        var arrTags_flag=false;
        for(var i=arr_current_before;i<=arr_current_after;i++){
            if(active_tag==arr_tags[i]){
                arrTags_flag=true;
                bpsviewer.call("set(hotspot["+active_tag+"].visible,true);");
                break;
            }
        }
        if(!arrTags_flag){
            var new_notes_width ='';
            var str_nickname = userData.userinfo.nickname;
            var str_notes=userData.note;   ////注意的title还是note
//            console.log('str_notes='+str_notes)
            var textShort_len=fucCheckLength(str_notes);
            var nameShort_len=fucCheckLength(str_nickname);
            if(textShort_len>=nameShort_len){
                new_notes_width='autowidth';
            }else{
                if(nameShort_len<5){
                    new_notes_width=90;
                }else{
                    new_notes_width=nameShort_len*18;
                }
            }
            //换成直接读取微信的头像  2015-09-12
            ownurl =userData.userinfo.headimgurl;
            bpsviewer.call("create_tag_table(" + userData.userinfo.userid + "," + str_notes + "," + str_nickname + "," + ownurl + "," + userData.ath + "," + userData.atv + "," + new_notes_width + ");");
            lone_name.push(active_tag);
        }
        bpsviewer.call("lookto(" + userData.ath + "," + userData.atv + ",2,smooth(100,50,20));");
        $(".fans_list_close").trigger('click');

    }
    function convertTaginfo(data)
    {
        var _taginfo = {};
        _taginfo.id = "usertag" + data._id;
        _taginfo.ath = data.ath;
        _taginfo.atv = data.atv;
        _taginfo.fov = data.fov;
        if(typeof(data.userinfo) == "object" )
        {
            _taginfo.avatarurl =  data.userinfo.headimgurl;
        }
        else
        {
            _taginfo.avatarurl = "/images/noavatar@96x96.jpg";
        }

        _taginfo.title = data.title;
        _taginfo.note = data.note;
        return _taginfo;
    }
    //标注标注点成功后的调用函数
    function CreateUsertagSuccess(taginfo)
    {
        //console.log (JSON.stringify(taginfo));
        var new_text_width='';
        var textShort_len=fucCheckLength(taginfo.note);
        var nameShort_len=fucCheckLength(taginfo.userinfo.nickname);
        if(textShort_len>=nameShort_len){
            new_text_width='autowidth';
        }else{
            if(nameShort_len<5){
                new_text_width=90;
            }else{
                new_text_width=nameShort_len*18;
            }
        }
        bpsviewer.call("create_tag("+taginfo.userinfo.userid+","+taginfo.note+","+taginfo.userinfo.nickname+","+taginfo.userinfo.headimgurl+","+new_text_width+");");
        bpsviewer.call("set(hotspot[tagger].visible,false);");
        var name_arr='new_tag_bar'+taginfo.userinfo.userid;
        lone_name.push(name_arr);
        $(".wx_y").slideUp(100);
        nav_show();
        getposition_share_id($.currentUser._id);
        wx_friend_name=$.currentUser.nickname;
    }
    //更新或修改标点
    function getTaginfoByUserId(uid,cb)
    {
        var _url = "/service/panos/" + panoinfo.panoid + "/usertags?userid="+uid;
        $.bigpixel.AjaxGetJson(_url,function(err,body){
            var data = body.data;

            if(!err && data.length > 0)
            {
                var _taginfo = convertTaginfo(data[0]);
                cb(_taginfo);
            }
            else
            {
                cb(null);
            }
        });
    }
    //保存标注点
    function saveTag()
    {
        if($.bigpixel.isLoggedIn()){
            //console.log(bpsviewer.get('hotspot[tagger].fov'));
            var data = {
                userid:$.currentUser._id,
                ath:bpsviewer.get('hotspot[tagger].ath'),
                atv:bpsviewer.get('hotspot[tagger].atv'),
                //fov:bpsviewer.get('hotspot[tagger].fov'),
                fov:2,
                note:$("input").val()
            };

            //如果当前用户已经有标注点，则修改标注点信息，否则创建新的标注点
            this.getTaginfoByUserId(data.userid,function(taginfo){
                if(taginfo != null)
                {
                    //修改标注点
                    var tagid =  taginfo.id.replace("usertag", "");
                    var _url = "/service/panos/" + panoinfo.panoid + "/usertags/"+tagid;
                    $.bigpixel.AjaxPutData(_url,data,function(err,data){
                        console.log("Put");
                       // console.log(data);
                        if(!err)
                        {
                            CreateUsertagSuccess(data);
                        }
                    });
                }
                else
                {
                    //新增标注点
                    var _url = "/service/panos/" + panoinfo.panoid + "/usertags";
                    $.bigpixel.AjaxPostData(_url,data,function(err,data){
                        console.log("Post");
                        //console.log(data);
                        if(!err)
                        {
                            CreateUsertagSuccess(data);
                        }
                    });
                }
            })
        }
        else
        {
            console.log("请登录");
        }
    }

    //隐藏所有标签
    var arr_current_before=0;
    var arr_current_after=0;
    var hid_flag=false;
    $(".eye").click(function(){
        if(hid_flag==false){
            curren_tags_hidden();
        }else{
            curren_tags_show();
        }
    });
    function curren_tags_hidden(){
        for(var i=arr_current_before;i<=arr_current_after;i++){
            bpsviewer.call("set(hotspot["+arr_tags[i]+"].visible,false);");
        }
        for(var i=0;i<lone_name.length;i++){
            bpsviewer.call("set(hotspot["+lone_name[i]+"].visible,false);");
        }
        $(".eye p").html("SHOW"); $(".eye i").addClass("icon-eye").removeClass("icon-eye-slash");
        hid_flag=true;
    }
    function curren_tags_show(){
        for(var i=arr_current_before;i<=arr_current_after;i++){
            bpsviewer.call("set(hotspot["+arr_tags[i]+"].visible,true);");
        }
        for(var i=0;i<lone_name.length;i++){
            bpsviewer.call("set(hotspot["+lone_name[i]+"].visible,true);");
        }
        $(".eye p").html("HIDDEN");$(".eye i").addClass("icon-eye-slash").removeClass("icon-eye");
        hid_flag=false;
    }
    //按刷新按钮的一批批加载分页查询
    var page_tag=0;
    var per_page_tag_num=20;
    var three_arr_url=[];
    var three_arr_id=[];
    $(".refresh").click(function(){
        page_tag++;
        getinfoskip(page_tag);
    });

    function getinfoskip(page_tag){
        $(".tag_loading").css("display","block");
        if(page_tag>0){
            var arr_index_before=(page_tag-1)*per_page_tag_num;
            var arr_index_after=(page_tag)*per_page_tag_num-1;
            arr_current_before=page_tag*per_page_tag_num;
            arr_current_after=(page_tag+1)*per_page_tag_num-1;
            for(var i=arr_index_before;i<=arr_index_after;i++){

                bpsviewer.call("set(hotspot["+arr_tags[i]+"].visible,false);");
            }
        }else{
            arr_current_before=0;
            arr_current_after=per_page_tag_num;
        }
        var  Tag_index=page_tag*per_page_tag_num;
        var _url="/service/panos/"+panoinfo.panoid+"/usertags?skip="+Tag_index+"&limit="+per_page_tag_num;
        $.bigpixel.AjaxGetJson(_url,function(err,data) {
            if (!err) {
                //返回的数据
                // console.log(JSON.stringify(data));
                //alert(JSON.stringify(data));
                var listData=data.data;
                if(listData.length==0){
                    getinfoskip(0);
                    page_tag=0;
                    return false;
                }
                three_arr_url.length=0;
                three_arr_id.length=0;
                for(var i=0;i<listData.length;i++){

                    //var ownurl= "http://srv.bigpixel.cn/api/picture/get?url="+listData[i].userinfo.headimgurl.replace("/0","/46");
                    var ownurl= listData[i].userinfo.headimgurl;
                    var str_nickname=listData[i].userinfo.nickname;
                    var str_notes=listData[i].note;    //注意的title还是note
                    var new_notes_width='';
                    var textShort_len=fucCheckLength(str_notes);
                    var nameShort_len=fucCheckLength(str_nickname);
                    if(textShort_len>=nameShort_len){
                        new_notes_width='autowidth';
                    }else{
                        if(nameShort_len<5){
                            new_notes_width=90;
                        }else{
                            new_notes_width=nameShort_len*18;
                        }
                    }
                    bpsviewer.call("create_tag_table("+listData[i].userinfo.userid+","+str_notes+","+str_nickname+","+ownurl+","+listData[i].ath+","+listData[i].atv+","+new_notes_width+");");
                    var name_arr='new_tag_bar'+listData[i].userinfo.userid;
                    arr_tags.push(name_arr);
                    three_arr_url.push(ownurl);
                    three_arr_id.push(listData[i].userinfo.userid);
                }
                $(".tag_loading").css("display","none");
            }
        });
    }

    function tag_area(){
        showdialog();
        nav_hidden();
    }
    //显示标注自己想说的话的input框-start
    function showdialog(){
        if($.bigpixel.isLoggedIn())
        {
            $(".wx_y").slideDown(100);
            var atv = Number( bpsviewer.get("view.vlookat") );
            var ath   = Number( bpsviewer.get("view.hlookat") );
            bpsviewer.call("set(hotspot[tagger].visible,true);");
            bpsviewer.call("set(hotspot[tagger].ath,"+ath+");");
            bpsviewer.call("set(hotspot[tagger].atv,"+atv+");");
            bpsviewer.call("set(plugin[usericon_avatar].url,"+ $.currentUser.avatarurl+");");
        }
        else
        {
            $(".wx_n").slideDown(100);
        }
    }
    //显示标注自己想说的话的input框-end
    //导航栏隐藏
    function nav_hidden(){
        $(".htmleaf-container").css("display","none");
    }
    //导航栏显示
    function nav_show(){
        $(".htmleaf-container").css("display","block");
    }
    //标注自己-end
    //<!--开始页面点击start消失-->
    $(document).ready(function(){
        $(".get_start_btn").click(function(){
            $(".get_start").css("display","none");
            $(".cover_hei").css("display","none");
            $(".start_banner").css("display","none");
            getinfoskip(0);
            setTimeout(function(){
                lookarea();     //点击按钮get_start后look_to share_id的地方或是默认地方
            },2000);

        });
    });

    //mobile端zoom点击
    var ZoomTouch = util.toucher($('#zoom')[0]);
    //console.log(bodyTouch);
    ZoomTouch.on('swipeStart','.zoom_in',function(e){
        bpsviewer.call("set(fov_moveforce,-0.25);");
    }).on('swipeEnd','.zoom_in',function(e){
        bpsviewer.call("set(fov_moveforce,0);");
    });
    ZoomTouch.on('swipeStart','.zoom_out',function(e){
        bpsviewer.call("set(fov_moveforce,+0.25);");
    }).on('swipeEnd','.zoom_out',function(e){
        bpsviewer.call("set(fov_moveforce,0);");
    });
    //PC端zoom按钮点击
    $(".zoom_in").mousedown(function(){
        bpsviewer.call("set(fov_moveforce,-0.25);");
    }).mouseup(function(){
        bpsviewer.call("set(fov_moveforce,0);");
    });
    $(".zoom_out").mousedown(function(){
        bpsviewer.call("set(fov_moveforce,+0.25);");
    }).mouseup(function(){
        bpsviewer.call("set(fov_moveforce,0);");
    });

    //菜单悬转动画-start
    var toggle = $('#ss_toggle');
    var menu = $('#ss_menu');
    var rot;
    $('#ss_toggle').on('click', function (ev) {
        rot = parseInt($(this).data('rot')) - 180;
        menu.css('transform', 'rotate(' + rot + 'deg)');
        menu.css('webkitTransform', 'rotate(' + rot + 'deg)');
        if (rot / 180 % 2 == 0) {
            menu.css("top",0);   //隐藏菜单出来时
            menu.css("width","80px");
            $("#ss_menu .icon-bg").css("display","block");
            $(".htmleaf-container").animate( {"bottom":"-30px"},500,function(){$(".tag_img").fadeOut(200);$(".tag_text").slideDown(400); });
        } else {
            menu.css("top",130); //隐藏菜单下去时
            menu.css("width",0);
            $(".htmleaf-container").animate( {"bottom":"3px"},500,function(){$(".tag_text").fadeOut(200);$(".tag_img").slideDown(100);
                $("#ss_menu .icon-bg").css("display","none");
            });
        }
        $(this).data('rot', rot);
    });
    menu.on('transitionend webkitTransitionEnd oTransitionEnd', function () {
        if (rot / 180 % 2 == 0) {
            $('#ss_menu div i').addClass('ss_animate');  //转出来后的上下来回晃动一下
        } else {
            $('#ss_menu div i').removeClass('ss_animate');  //转出来后的上下来回晃动一下
        }
    });
    //菜单悬转动画-end
    //点击fans按钮生成列表-start
    var woman_flag=true;
    var man_flag=true;
    var woman_page=0;
    var man_page=0;
    var pullUp_man_flag=false;
    var pullUp_woman_flag=false;
    var active_who_page=true;
    $(".fans_btn").click(function(){
        $(".fans_list_box").css("display","block");
        $(".cover_hei").css("display","block");
        if (rot / 180 % 2 == 0){
            $("#ss_toggle").trigger("click");
        }
        if(woman_flag){
            getfemale();
        }
    });
    //获取粉丝窝(男粉)
    function getmale(){
        var man_fans_html='';
        var limit_num=6;
        var male_index=man_page*limit_num;
        var _url = "/service/panos/" + panoinfo.panoid + "/usertags?skip="+male_index+"&limit="+limit_num+"&gendar=1";
        $.bigpixel.AjaxGetJson(_url,function(err,data) {
            if (!err) {
                var list_data=data.data;
                if(list_data.length!=0){
                    for(var i=0;i<list_data.length;i++){
                        // console.log(data[i].userinfo.headimgurl);
                        var usename=list_data[i].userinfo.nickname;
                        if(usename.length>=5) {
                            usename = usename.substring(0, 5);
                        }
                        var strtaginfo = JSON.stringify(list_data[i]);
                        //console.log(strtaginfo);
                        var ff=list_data[i].userinfo.userid;
                        man_fans_html+=  '<li><div class="fans_head_img fl"><img src="'+list_data[i].userinfo.headimgurl.replace("/0","/96")+'"/></div>\
					<div class="fans_text fl"><p class="nickname">'+usename+'</p><p class="text">'+list_data[i].note+'</p></div>\
					<div class="fans_tag_area fr"><a class="zoom_self fl" href="javascript:void(0);" onclick=\'looktoTag('+strtaginfo+')\'><span class="icon-crosshairs"></span></a></div></li>';
                    }
                    $("#fans_list_man").append(man_fans_html  );
                    var list_man_h=parseInt($("#fans_list_man").height());
                    if(list_man_h>300){
                        $(".pullUp_man").css("display","table");
                        pullUp_man_flag=true;
                        $(".pullUp_man .pullUpLabel").html('加载更多...');
                    }else{
                        $(".pullUp_man").css("display","none");
                    }
                }else{
                    if(man_page==0){
                        $(".pullUp_man").css("display","table");
                        pullUp_man_flag=true;
                        $(".pullUp_man .pullUpLabel").html('还没有更多男粉丝，来抢沙发吧');
                    }else{
                        $(".pullUp_man").css("display","none");
                    }
                }
                $(".pullUp_man").removeClass('loading');
            }
        });
        man_flag=false;
    }

    //获取粉丝窝(女粉)
    function getfemale(){
        var woman_fans_html='';
        var limit_num=6;
        var male_index=woman_page*limit_num;
        var _url = "/service/panos/" + panoinfo.panoid + "/usertags?skip="+male_index+"&limit="+limit_num+"&gendar=2";
        $.bigpixel.AjaxGetJson(_url,function(err,data) {
            if (!err) {
                //console.log(JSON.stringify(data));
                var list_data=data.data;
                if(list_data.length!=0){
                    for(var i=0;i<list_data.length;i++){
                        // console.log(data[i].userinfo.headimgurl);
                        var usename=list_data[i].userinfo.nickname;
                        if(usename.length>=5) {
                            usename = usename.substring(0, 5);
                        }
                        var strtaginfo = JSON.stringify(list_data[i]);
                        var ff=list_data[i].userinfo.userid;
                        woman_fans_html+=  '<li><div class="fans_head_img fl"><img src="'+list_data[i].userinfo.headimgurl.replace("/0","/96")+'"/></div>\
					<div class="fans_text fl"><p class="nickname">'+usename+'</p><p class="text">'+list_data[i].note+'</p></div>\
					<div class="fans_tag_area fr"><a class="zoom_self fl" href="#" onclick=\'looktoTag('+strtaginfo+')\'>\
					<span class="icon-crosshairs"></span></a></div></li>';
                    }
                    $("#fans_list_woman").append(woman_fans_html  );
                    var list_woman_h=parseInt($("#fans_list_woman").height());
                    if(list_woman_h>300){
                        $(".pullUp_woman").css("display","table");
                        pullUp_woman_flag=true;
                        $(".pullUp_woman .pullUpLabel").html('加载更多...');
                    }else{ $(".pullUp_woman").css("display","none"); }
                }else{
                    if(woman_page==0){
                        $(".pullUp_woman").css("display","table");
                        pullUp_woman_flag=true;
                        $(".pullUp_woman .pullUpLabel").html('还没有更多女粉丝，来抢沙发吧');
                    }else{
                        $(".pullUp_woman").css("display","none");
                    }
                }
                $(".pullUp_woman").removeClass('loading');
            }
        });
        woman_flag=false;
    }
    //女粉丝按钮点击
    $(".woman_btn").click(function(){
        active_who_page=true;
        $("#fans_list_woman").css("display","block");
        $("#fans_list_man").css("display","none");
        $(".pullUp_man").css("display","none");
        if(pullUp_woman_flag){
            $(".pullUp_woman").css("display","table");
        }else{$(".pullUp_woman").css("display","none");}
        $(this).addClass("fans_head_cur").siblings().removeClass("fans_head_cur");
    });
    //男粉丝按钮点击
    $(".man_btn").click(function(){
        active_who_page=false;
        $(".pullUp_woman").css("display","none");
        if(pullUp_man_flag){
            $(".pullUp_man").css("display","table");
        }else{$(".pullUp_man").css("display","none");}
        if(man_flag){
            getmale();
            $("#fans_list_woman").css("display","none");
            $("#fans_list_man").css("display","block");
        }else{
            $("#fans_list_man").css("display","block");
            $("#fans_list_woman").css("display","none");
        }
        $(this).addClass("fans_head_cur").siblings().removeClass("fans_head_cur");
    });
    //男女粉丝列表关闭
    $(".fans_list_close").click(function(){
        $(".fans_list_box").css("display","none");
        $(".cover_hei").css("display","none");
    });
    //点击fans按钮生成列表end
    //列表页滚动条滚动到底部触发事件-start
    var nScrollHight = 0; //滚动距离总长(注意不是滚动条的长度)
    var nScrollTop = 0; //滚动到的当前位置
    $(".list_inner").scroll(function(){
        var nDivHight = $(".fans_list_box .list_inner").height();
        var nDivHight_game = $(".game_list_box .list_inner").height();
        nScrollHight = $(this)[0].scrollHeight;
        nScrollTop = $(this)[0].scrollTop;
        if((nScrollTop + nDivHight) >= nScrollHight){
            if(active_who_page){
                //console.log('滚动触发女粉');
                woman_page++;
                $(".pullUp_woman").addClass('loading'); $(".pullUp_woman .pullUpLabel").html('Loading...');
                getfemale();
            }else{
                //console.log('滚动触发男粉');
                man_page++;
                $(".pullUp_man").addClass('loading'); $(".pullUp_man .pullUpLabel").html('Loading...');
                getmale();
            }
        }
        if((nScrollTop + nDivHight_game) >= nScrollHight){
            if(game_scoll){
                //console.log('滚动触发game-score');
                skip++;
                $(".pullUp_game_score").addClass('loading'); $(".pullUp_game_score .pullUpLabel").html('Loading...');
                game_score_list();
            }
        }
    });
    //列表页滚动条滚动到底部触发事件-end

    $(document).ready(function() {
        initPanoview();
        //下面目的是如果刚开始按login登陆进来让开始页面隐藏
        if($.bigpixel.isLoggedIn())
        {
            var _url="/service/panos/"+panoinfo.panoid+"/usertags?userid="+$.currentUser._id;
            $.bigpixel.AjaxGetJson(_url,function(err,data) {
                if (!err) {
                   // console.log(JSON.stringify(data));
                    if(data.data[0].note) {   //判断如果链接上的用户有说过话且链接上的id号不等于当前的id号时进行zoom到链接上的位置
                        $(".wx_y").slideDown(100);
                        var atv = Number( bpsviewer.get("view.vlookat") );
                        var ath   = Number( bpsviewer.get("view.hlookat") );
                        bpsviewer.call("set(hotspot[tagger].visible,true);");
                        bpsviewer.call("set(hotspot[tagger].ath,"+ath+");");
                        bpsviewer.call("set(hotspot[tagger].atv,"+atv+");");
                        bpsviewer.call("set(plugin[usericon_avatar].url,"+ $.currentUser.avatarurl+");");
                        $(".get_start").css("display","none");
                        $(".cover_hei").css("display","none");
                        $(".start_banner").css("display","none");
                        getinfoskip(0);
                    }
                }
            });
        }
    });
</script>
<!--game相关函数-start-->
<script>
    var game_toggle_flag=true;
    var game_scoll=false;
    var skip=0;
    var  score_record=false;        //如果为true说明当前用户刚进入页面时的不为零
    $(".game_btn").on('click',function(){
        if(game_toggle_flag){
            game_home_go();
            game_toggle_flag=false;
            $(".game_btn").animate({"top":56},500);
        }else{
            fans_home_go();
            game_toggle_flag=true;
            $(".game_btn").animate({"top":2},500);
        }
        if(!score_record){
            bpsviewer.call("zoom_to_firsthot();");
        }
        if(!$.bigpixel.isLoggedIn())
        {
            $.bigpixel.login();
        }
    });
    function fans_home_go(){
        $(".fans_btn").css("display","block");
        $(".refresh").css("display","block");
        $(".htmleaf-container").css("display","block");
        $(".game-area").css("display","none");
        curren_tags_show();
        $(".game_btn span").addClass("icon-gamepad").removeClass("icon-user");
        $(".game_btn p").html("GAME");
        bpsviewer.call("set(hotspot[click_firsthot].visible,false);");
        curren_game_hot_hidden();
    }
    function game_home_go(){
        $(".fans_btn").css("display","none");
        $(".refresh").css("display","none");
        $(".htmleaf-container").css("display","none");
        $(".game-area").css("display","block");
        curren_tags_hidden();
        $(".game_btn span").addClass("icon-user").removeClass("icon-gamepad");
        $(".game_btn p").html("FANS");
        $(".tag_loading").css("display","none");
        curren_game_hot_show();
    }
    $(".tip").click(function(){
        $(this).parent().css("display","none");
    });
    $(".game_list_close .icon-close").click(function(){
        $(".game_list_box").css("display","none");
        $(".cover_hei").css("display","none");
    });
    $(".rank_btn").click(function(){
        $(".game_list_box").css("display","block");
        game_score_list();
        $(".cover_hei").css("display","block");
    });
    //生成game-list积分列表
    function game_score_list(){
        var limit=6;
        var game_list_html='';
        $.ajax({
            type: "get",
            //方法所在页面和方法名
            url: "/service/games/5653ca8ce0fd2cba0d2966f5/rank?skip="+skip+'&limit='+limit,
            data:{},
            dataType: "json",
            success: function (data) {
                console.log('当前game_score的长度='+data.length);
                if(data.length!=0){    //如果当前页有数据
                    for(var key in data){
                        var usename=data[key].nickname;
                        if(usename.length>=5) {
                            usename = usename.substring(0, 5);
                        }
                        game_list_html+=  ' <li><div class="game_head_img fl"><img src="'+data[key].headimgurl+'" width="100%"/></div>\
                        <div class="game_text fl"><p class="nickname">'+usename+'</p> </div>\
                        <div class="game_tag_area fr"><p class="score">'+data[key].score+'</p></div></li>';
                    }
                    $(".game_list").append(game_list_html  );
                    var list_man_h=parseInt($(".game_list").height());
                    if(list_man_h>300){
                        $(".pullUp_game_score").css("display","table");
                        $(".pullUp_game_score .pullUpLabel").html('加载更多...');
                        game_scoll=true;    //打开如果game列表有滚动条
                    }else{
                        $(".pullUp_game_score").css("display","none");
                    }
                }else{   //如果当前页没有数据
                    if(skip==0){   //如果当前页没有数据且是第一页
                        $(".pullUp_game_score").css("display","table");
                        $(".pullUp_game_score .pullUpLabel").html('还没有更多排名，快来玩游戏吧');
                    }else{   //如果当前页没有数据且不是第一页
                        $(".pullUp_game_score").css("display","none");
                    }
                }
                $(".pullUp_game_score").removeClass('loading');

            },
            error: function (err) {
            }
        });
    }
    //隐藏当前所有的小黑人的hot
    function curren_game_hot_hidden(){
        for(var i=1;i<=20;i++){
            bpsviewer.call("set(hotspot[game_hot"+i+"].visible,false);");
        }
    }
    //显示当前用户还没有点击的小黑人的hot
    var curren_game_show=true;
    function curren_game_hot_show(){
        if(curren_game_show){
            bpsviewer.call("create_game_hots();");
            curren_game_show=false;
        }else{
            for(var i=1;i<=20;i++){
                bpsviewer.call("set(hotspot[game_hot"+i+"].visible,true);");
            }
        }
        hidden_game_hot();   <!-- 隐藏上次已经点过的game_hot-->
    }
    //点击第一个或最后一个小黑人时的提示框
    function game_hots_tip(num1){
        if(num1==1){$(".start_game_tip").css("display","block");}else if (num1==20){   $(".end_game_tip").css("display","block");}
    }
    //获得当前用户的积分
    function get_game_score(){
        if($.currentUser._id){
            $.ajax({
                type: "get",
                //方法所在页面和方法名
                url: "/service/games/5653ca8ce0fd2cba0d2966f5/score/",
                data:{userid:$.currentUser._id},
                dataType: "json",
                success: function (data) {

                    var score=data[0].score;
                    //console.log('积分=',score) ;
                    bpsviewer.set("game_hot_from_data",score);
                    $(".found-area .num1").html(score);
                    if(score>0){
                        score_record=true;
                    }
                },
                error: function (err) {
                }
            });
        }
    }
    //每点击一次小黑人会传送积分和name值
    function score_add(score_num,game_hot_name){
        $(".found-area .num1").html(score_num);
        //console.log(game_hot_name);
        if($.currentUser._id){
            $.ajax({
                type: "post",
                //方法所在页面和方法名
                url: "/service/games/5653ca8ce0fd2cba0d2966f5/score/",
                data:{userid:$.currentUser._id,dots:game_hot_name},
                dataType: "json",
                success: function (data) {
                },
                error: function (err) {
                }
            });
        }else{
            //未登录需要按钮提交字符串给后台
            var game_name_str='';
            game_name_str=game_name_str+game_hot_name+',';
        }
    }
    //隐藏掉在上次已经点过的小黑人的hot
    function hidden_game_hot(){
        $.ajax({
            type: "get",
            //方法所在页面和方法名
            url: "/service/games/5653ca8ce0fd2cba0d2966f5/records/",
            data:{userid:$.currentUser._id},
            dataType: "json",
            success: function (data) {
                //console.log(data.length)
                for(var i=0;i<data.length;i++){
                    bpsviewer.call("set(hotspot[game_hot"+data[i].dot+"].visible,false);");
                }
            },
            error: function (err) {
            }
        });
    }
    $(".game-area").css({"margin-left":0,"left":0});
    $(".user-area .user-name").addClass("mob_user_cur");
    $(".game-area p").css({"font-size":"12px","height":40});
    $(".found-area .user-num").css("padding-left","10%");
    $(".get_start .get_start_btn").css("width","66%");
//    $(".start_banner img").css({"height":"auto","width":"80%"});
    $(".user-num").css({"margin-left":0,"left":0});
    $(".rank-area img").css({"width":"100%","height":"auto","padding-top":4});
</script>
<!--game相关函数-end-->
<!--换粉丝头像-start-->
<script>
    $('.togg_three_btn').on('click',function(){
        var three_bottom=parseInt($(".three_btn").css("top"));
        if(three_bottom==55){
            $(".three_btn").animate({'top':-60},500);
        }else{
            $(".three_btn").animate({'top':55},500);
        }
    });
    $(".three_btn .btn1").click(function(){
        for(var i=0;i<per_page_tag_num;i++){
            bpsviewer.call("set(plugin[new_tag"+three_arr_id[i]+"].url,"+three_arr_url[i]+");");
        }
    });
    $(".three_btn .btn2").click(function(){
        for(var i=0;i<(per_page_tag_num/2);i++){
            bpsviewer.call("set(plugin[new_tag"+three_arr_id[i]+"].url,/stylesheets/images/team1.png);");
        }
        for(var i=per_page_tag_num/2;i<per_page_tag_num;i++){
            bpsviewer.call("set(plugin[new_tag"+three_arr_id[i]+"].url,/stylesheets/images/team2.png);");
        }
    });
    $(".three_btn .btn3").click(function(){
        for(var i=0;i<per_page_tag_num;i++){
            bpsviewer.call("set(plugin[new_tag"+three_arr_id[i]+"].url,/stylesheets/images/team.png);");
        }
    });
    $(".game_btn").on('click',function(){
        $(".three_btn").animate({'top':-60},500);
    });
    function loading(){
        $(".site-loading").css("display","none");
    }
</script>
<!--换粉丝头像-end-->
<!--微信分享设置-->
<script>
    socialinfo = {
        title:wx_friend_name+"在<%= title%>",
        desc:"<%= description%>",
        link:window.location.href.replace(window.location.hash, ''),
        imgUrl:'<%= iconPath%>'
    };
    <!-- 微信分享 -->
    var ua = navigator.userAgent.toLowerCase();
    if(ua.match(/MicroMessenger/i)=="micromessenger") {
        (function(){
            var jweixin = document.createElement("script");jweixin.src = "http://res.wx.qq.com/open/js/jweixin-1.0.0.js";
            var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(jweixin, s);
        })();
        setTimeout("initWechatShare();",3000);
    }
    function initWechatShare() {
        $.getJSON('http://srv.bigpixel.cn/api/weixin/getsignature?url=' + encodeURIComponent(socialinfo.link)).done(function (data) {
            console.log(data);
            wx.config({debug: false, appId: data.appId, timestamp: data.timestamp, nonceStr: data.nonceStr, signature: data.signature, jsApiList: ['onMenuShareTimeline', 'onMenuShareQQ', 'onMenuShareAppMessage', 'onMenuShareWeibo']});
            wx.ready(function () {
                wx.onMenuShareTimeline(socialinfo);
                wx.onMenuShareAppMessage(socialinfo);
                wx.onMenuShareQQ(socialinfo);
                wx.onMenuShareWeibo(socialinfo);
            });
        });
    }
</script>
<!-- 谷歌、百度统计代码 -->
<script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-56983622-1');ga('send', 'pageview');
    var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?00e4d98773c02201bbd493815c0cb964"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s);})();
</script>
</body>
</html>